package com.stars.home.activity

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import com.qmuiteam.qmui.kotlin.onClick
import com.stars.home.base.MBActivity
import com.stars.home.config.MIntentAction
import com.stars.home.databinding.ActivityInvoiceBinding
import com.stars.home.vmodel.InvoiceVModel
import com.trailer.base.utils.UiSwitch

/**
 *on 2021/5/9
 */
class InvoiceActivity : MBActivity<InvoiceVModel, ActivityInvoiceBinding>() {


    override fun init(savedInstanceState: Bundle?) {
        super.init(savedInstanceState)

        titleBar()?.tvRight?.text="我的申请列表"

    }

    override fun listeners() {
        super.listeners()

        titleBar()?.tvRight?.onClick {
            //申请列表
            UiSwitch.single(context(),InvoiceListActivity::class.java)

        }

        binding.llChoseOrder.onClick {
            //选择订单
            UiSwitch.singleRes(this, InvoiceOrderActivity::class.java, MIntentAction.REQUEST_CODE_ONE)


        }

        binding.llSubmit.onClick {
            //提交
            vm.toSubmit()
        }
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (MIntentAction.REQUEST_CODE_ONE === requestCode && resultCode == Activity.RESULT_OK) {
            val bundle = data!!.extras
            if (null != bundle) {
                vm.tips.value="已选订单"
                vm.order_ids = bundle.getString("order_ids")!!

            }

        }

    }


    override fun title(): String? {
        return "开具发票"
    }

    override fun vmClass(): Class<InvoiceVModel> {
        return InvoiceVModel::class.java
    }

    override fun binding(): ActivityInvoiceBinding {
        return ActivityInvoiceBinding.inflate(layoutInflater)
    }
}
